<?php

class Application_Form_Ocupaciones extends Sgit_Form
{

    public function init_form()
    {
        $request = Zend_Controller_Front::getInstance()->getRequest();
        $id = $request->getParam('id');


        $peticion =     Sgit_Util_FileUpload::run('ocupaciones','file');



        $ubicacion = new Sgit_Form_Element_Select_Year('anio');
        $ubicacion->setRequired();
        $this->addElement($ubicacion);

        $element = new Sgit_Form_Element_Select_Mes('mes');
        $element->setRequired();
        $this->addElement($element);

 

        $files_0=new Zend_Form_Element_File($peticion['name']);
       
        $files_0->setLabel('Adjunto')
                ->setDestination($peticion['dir'])
                ->addValidator('Size', false, 31457280)
                ->setValueDisabled(true);
        $this->addElement($files_0);


        if($id){
             $options=Sgit_Util_GetFiles::run($peticion['tabla'],$peticion['key'],$id);
             
             if($options){
                 $files_lista0 = new Zend_Form_Element_MultiCheckbox($peticion['activo']);
                 $files_lista0->setMultiOptions($options)
                    ->setLabel('Borrar Adjunto')
                    ->setAttrib('size',25); 
                 $this->addElement($files_lista0);
             }
         }
         
         


        $notas = new Zend_Form_Element_Textarea('notas');
        $notas->setLabel('Notas')->setAttribs(array('rows' => 3, 'cols' => 60));
        $this->addElement($notas);


        $this->setElementDecorators($this->getDecoratorElement());

        //fix file 

        $files_0->setDecorators($this->getDecoratorFile());

    }
}
